package com.jason.concurrent.readWriter;

import java.nio.channels.ReadableByteChannel;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * @Author  yslai
 * @Date  2022/9/20 9:19
 * @Description 降级等操作
 */
public class Rw {



    public static void main(String[] args) {
        //开启一个写锁的状态
        ReadWriteLock lock = new ReentrantReadWriteLock();
        lock.writeLock().lock();

        System.out.println("write");

        lock.readLock().lock();
        System.out.println("read");
        lock.writeLock().unlock();
        lock.readLock().unlock();

    }
}
